import time

import allure
from selenium.webdriver import Keys, ActionChains
from selenium.webdriver.common.by import By

from src.PO.base import Base



@allure.feature("商品编辑界面")
class ProductEidtPage(Base):
    __MARKET=(By.CSS_SELECTOR,".el-input.el-input--mini.el-input-group.el-input-group--append>input")
    __UPDATE_DUTTON=(By.XPATH, "//*[text()='更新商品']")
    def modify_market_price(self):
        from src.PO.product_list_page import ProductListPage
        with allure.step("修改市场售价"):
            self.find_and_click(*self.__MARKET)
            time.sleep(1)
            ActionChains(self.driver).key_down(Keys.CONTROL).send_keys("a").key_up(Keys.CONTROL).perform()
            self.find_and_send(*self.__MARKET,text="268")
            update_button = self.find(*self.__UPDATE_DUTTON)
            ActionChains(self.driver).scroll_to_element(update_button).perform()  # 滚动鼠标
            update_button.click()
        return ProductListPage(self.driver)